//
//  LJTalentCell.m
//  BaseProject
//
//  Created by 王洋 on 2020/12/11.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "LJTalentCell.h"

@implementation LJTalentCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        
        [self.mainImageView pp_clipCorners:UIRectCornerAllCorners radius:self.mainImageView.frame.size.height/2];
        
    });
}

- (void)fillWithModel:(CommunitySellerModel *)model {
    
    [self.mainImageView sd_setImageWithURL:[NSURL URLWithString:model.sellerHeadUrl] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    self.mainTitleLab.text = model.sellerName;
    
    
//    self.subTitleLab.text = [NSString stringWithFormat:@"已回答%@个问题",model.uaCount];
    
    NSString *countStr = model.uaCount;
    NSInteger count = model.uaCount.integerValue;
    if (count > 0) {
        countStr = model.uaCount;
    } else {
        countStr = @"*";
    }
    
    NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"已回答%@个问题",countStr]];
     
     [attribtStr addAttribute:NSForegroundColorAttributeName value:UIColorHex(0x999999) range:NSMakeRange(0,3)];
     [attribtStr addAttribute:NSForegroundColorAttributeName value:UIColorHex(0xFF7200) range:NSMakeRange(3,countStr.length)];
    [attribtStr addAttribute:NSForegroundColorAttributeName value:UIColorHex(0x999999) range:NSMakeRange(countStr.length+3,3)];


     //赋值
     self.subTitleLab.attributedText = attribtStr;
    
    switch (model.index) {
        case 0:{
            
            [self.maskImageView setImage:[UIImage imageNamed:@"diyi_icon"]];
        } break;
        case 1:{
            [self.maskImageView setImage:[UIImage imageNamed:@"dier_icon"]];
        } break;
        case 2:{
            [self.maskImageView setImage:[UIImage imageNamed:@"disan_icon"]];
        } break;
        default:{
            [self.maskImageView setImage:[UIImage imageNamed:@""]];
        } break;
    }
}

@end
